package sort;

import java.util.*;

/**
 * @author XY
 * @version 1.0
 * @date 2022/3/21 9:10
 * @Description
 */
public class Leet594 {

    public Leet594(String a){
        System.out.println(a);
    }

    public static int findLHS(int[] nums) {
        Map<Integer,Integer> map = new HashMap<>();
        for (int num : nums) {
            map.put(num,map.getOrDefault(num,0)+1);
        }
        int max = 0;
        for (Integer integer : map.keySet()) {
            if(map.get(integer+1)!=null){
                int i = map.get(integer) + map.get(integer + 1);
                max = max> i ?max:i;
            }
        }
        return max;
    }

    public static void main(String[] args) {
        Leet594 a = new Leet594("!");
        int[] arr = {2,2,2,2,2,2,2,3,1,0,0,0,3,1,-1,0,1,1,0,0,1,1,2,2,2,0,1,2,2,3,2};
        System.out.println(findLHS(arr));
    }
}
